using System;
using System.Collections;
using System.DirectoryServices;

namespace BEGDC.CC.Entity
{
	#region ActionPoint

	/// <summary>
	/// ActionPoint object for NHibernate mapped table 'ActionPoint'.
	/// </summary>
	[Serializable]
	public class ActionPoint : System.IComparable
		{
		#region Member Variables
		
		protected int _id;
		protected long _flowID;
		protected string _aPType;
		protected string _status;
		protected string _priority;
		protected string _classifictaion;
		protected string _cAT;
		protected string _description;
		protected string _operatorName;
		protected string _aPNo;
		protected Nullables.NullableDateTime _dueTime;
		protected string _attachmentList;
		protected Nullables.NullableDateTime _closedDate;
		protected EVMeeting _eVMeeting;
		protected DicItem _dicItem;
		protected Employee _actionOwner;
		protected IList _aPPartners;
		protected IList _aPCommentses;
		protected IList _attachments;
		protected static String _sortExpression = "Id";
		protected static SortDirection _sortDirection = SortDirection.Ascending;

		#endregion

		#region Constructors

		public ActionPoint() { }

		public ActionPoint( long flowID, string aPType, string status, string priority, string classifictaion, string cAT, string description, string operatorName, string aPNo, Nullables.NullableDateTime dueTime, string attachmentList, Nullables.NullableDateTime closedDate, EVMeeting eVMeeting, DicItem dicItem, Employee actionOwner )
		{
			this._flowID = flowID;
			this._aPType = aPType;
			this._status = status;
			this._priority = priority;
			this._classifictaion = classifictaion;
			this._cAT = cAT;
			this._description = description;
			this._operatorName = operatorName;
			this._aPNo = aPNo;
			this._dueTime = dueTime;
			this._attachmentList = attachmentList;
			this._closedDate = closedDate;
			this._eVMeeting = eVMeeting;
			this._dicItem = dicItem;
			this._actionOwner = actionOwner;
		}

		#endregion

		#region Public Properties

		public int Id
		{
			get {return _id;}
			set {_id = value;}
		}

		public long FlowID
		{
			get { return _flowID; }
			set { _flowID = value; }
		}

		public string APType
		{
			get { return _aPType; }
			set
			{
				if ( value != null && value.Length > 20)
					throw new ArgumentOutOfRangeException("Invalid value for APType", value, value.ToString());
				_aPType = value;
			}
		}

		public string Status
		{
			get { return _status; }
			set
			{
				if ( value != null && value.Length > 20)
					throw new ArgumentOutOfRangeException("Invalid value for Status", value, value.ToString());
				_status = value;
			}
		}

		public string Priority
		{
			get { return _priority; }
			set
			{
				if ( value != null && value.Length > 20)
					throw new ArgumentOutOfRangeException("Invalid value for Priority", value, value.ToString());
				_priority = value;
			}
		}

		public string Classifictaion
		{
			get { return _classifictaion; }
			set
			{
				if ( value != null && value.Length > 20)
					throw new ArgumentOutOfRangeException("Invalid value for Classifictaion", value, value.ToString());
				_classifictaion = value;
			}
		}

		public string CAT
		{
			get { return _cAT; }
			set
			{
				if ( value != null && value.Length > 20)
					throw new ArgumentOutOfRangeException("Invalid value for CAT", value, value.ToString());
				_cAT = value;
			}
		}

		public string Description
		{
			get { return _description; }
			set
			{
				if ( value != null && value.Length > 500)
					throw new ArgumentOutOfRangeException("Invalid value for Description", value, value.ToString());
				_description = value;
			}
		}

		public string OperatorName
		{
			get { return _operatorName; }
			set
			{
				if ( value != null && value.Length > 100)
					throw new ArgumentOutOfRangeException("Invalid value for OperatorName", value, value.ToString());
				_operatorName = value;
			}
		}

		public string APNo
		{
			get { return _aPNo; }
			set
			{
				if ( value != null && value.Length > 250)
					throw new ArgumentOutOfRangeException("Invalid value for APNo", value, value.ToString());
				_aPNo = value;
			}
		}

		public Nullables.NullableDateTime DueTime
		{
			get { return _dueTime; }
			set { _dueTime = value; }
		}

		public string AttachmentList
		{
			get { return _attachmentList; }
			set
			{
				if ( value != null && value.Length > 250)
					throw new ArgumentOutOfRangeException("Invalid value for AttachmentList", value, value.ToString());
				_attachmentList = value;
			}
		}

		public Nullables.NullableDateTime ClosedDate
		{
			get { return _closedDate; }
			set { _closedDate = value; }
		}

		public EVMeeting EVMeeting
		{
			get { return _eVMeeting; }
			set { _eVMeeting = value; }
		}

		public DicItem DicItem
		{
			get { return _dicItem; }
			set { _dicItem = value; }
		}

		public Employee ActionOwner
		{
			get { return _actionOwner; }
			set { _actionOwner = value; }
		}

		public IList APPartners
		{
			get
			{
				if (_aPPartners==null)
				{
					_aPPartners = new ArrayList();
				}
				return _aPPartners;
			}
			set { _aPPartners = value; }
		}

		public IList APCommentses
		{
			get
			{
				if (_aPCommentses==null)
				{
					_aPCommentses = new ArrayList();
				}
				return _aPCommentses;
			}
			set { _aPCommentses = value; }
		}

		public IList Attachments
		{
			get
			{
				if (_attachments==null)
				{
					_attachments = new ArrayList();
				}
				return _attachments;
			}
			set { _attachments = value; }
		}

        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
		#endregion
		
        #region IComparable Methods
        public int CompareTo(object obj)
        {
			if (!(obj is ActionPoint))
				throw new InvalidCastException("This object is not of type ActionPoint");
			
			int relativeValue;
			switch (SortExpression)
			{
				case "Id":
					relativeValue = this.Id.CompareTo(((ActionPoint)obj).Id);
					break;
				case "FlowID":
					relativeValue = this.FlowID.CompareTo(((ActionPoint)obj).FlowID);
					break;
				case "APType":
						relativeValue = ( this.APType != null ) ? this.APType.CompareTo(((ActionPoint)obj).APType) : -1;
					break;
				case "Status":
						relativeValue = ( this.Status != null ) ? this.Status.CompareTo(((ActionPoint)obj).Status) : -1;
					break;
				case "Priority":
						relativeValue = ( this.Priority != null ) ? this.Priority.CompareTo(((ActionPoint)obj).Priority) : -1;
					break;
				case "Classifictaion":
						relativeValue = ( this.Classifictaion != null ) ? this.Classifictaion.CompareTo(((ActionPoint)obj).Classifictaion) : -1;
					break;
				case "CAT":
						relativeValue = ( this.CAT != null ) ? this.CAT.CompareTo(((ActionPoint)obj).CAT) : -1;
					break;
				case "Description":
						relativeValue = ( this.Description != null ) ? this.Description.CompareTo(((ActionPoint)obj).Description) : -1;
					break;
				case "OperatorName":
						relativeValue = ( this.OperatorName != null ) ? this.OperatorName.CompareTo(((ActionPoint)obj).OperatorName) : -1;
					break;
				case "APNo":
						relativeValue = ( this.APNo != null ) ? this.APNo.CompareTo(((ActionPoint)obj).APNo) : -1;
					break;
				case "DueTime":
						relativeValue = ( this.DueTime != null ) ? this.DueTime.CompareTo(((ActionPoint)obj).DueTime) : -1;
					break;
				case "AttachmentList":
						relativeValue = ( this.AttachmentList != null ) ? this.AttachmentList.CompareTo(((ActionPoint)obj).AttachmentList) : -1;
					break;
				case "ClosedDate":
						relativeValue = ( this.ClosedDate != null ) ? this.ClosedDate.CompareTo(((ActionPoint)obj).ClosedDate) : -1;
					break;
                default:
                    goto case "Id";
			}
            if (ActionPoint.SortDirection == SortDirection.Ascending)
				relativeValue *= -1;
			return relativeValue;
		}
		#endregion
	}

	#endregion
}
